package com.demo.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.module.commonui.R;

public class SettingItemCheckBoxViewEx extends SettingItemCheckBoxView {
    private String mMark;
    private int mMarkTextSize = 10;
    public SettingItemCheckBoxViewEx(Context context) {
        super(context);
        initContentView();
    }

    public SettingItemCheckBoxViewEx(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SettingItemCheckBoxViewEx(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initParam(context, attrs);
        initContentView();
    }

    private void initParam(Context context, @Nullable AttributeSet attrs) {
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SettingItemCheckBoxViewEx);
        mMark = typedArray.getString(R.styleable.SettingItemCheckBoxViewEx_checkbox_text_mark);
        mMarkTextSize = (int)typedArray.getInt(R.styleable.SettingItemCheckBoxViewEx_checkbox_text_mark_size, mMarkTextSize);
        typedArray.recycle();
    }

    @Override
    public int getLayoutResID() {
        return R.layout.settings_item_checkbox_ex;
    }
    
    private void initContentView() {
        TextView tvMark = mView.findViewById(R.id.tv_item_text_mark);
        tvMark.setText(mMark);
        tvMark.setTextSize(mMarkTextSize);
    }

    public void setMark(String mark){
        mMark = mark;
        TextView tvMark = mView.findViewById(R.id.tv_item_text_mark);
        tvMark.setText(mMark);
    }

}
